<?php
	//----------------------- INPUT ELEMENTS -------------------//
	$ssFilter 		= $this->arrParam['ssFilter'];
	$selectLanguages = $ssFilter['lang_code'] . $this->formHidden('lang_code',$ssFilter['lang_code']);
	$name 					= $this->formText ( 'name', $this->Item['name'], array ('class' => 'txtlong active', 'onchange'=>"get_alias()") );
	$giagiam 				= $this->formText ( 'giagiam', $this->Item['giagiam'], array ('class' => 'txt active', 'onchange'=>"get_alias()") );
	$phantram 				= $this->formText ( 'phantram', $this->Item['phantram'], array ('class' => 'txtl active', 'onchange'=>"get_alias()") );
	//$selectClb			= $this->formSelect('id_clb',$this->Item['id_clb'],array('size'=>0,'style'=>'min-width:200px;'),$this->slbClb);
	
	$optionsGio=array("00" => '00',"01"=> '01',"02"=> '02',"03"=> '03',"04"=> '04',"05"=> '05',"06"=> '06',"07"=> '07',"08"=> '08',"09"=> '09');
	for ($i = 10; $i <= 23; $i++){
		$optionsGio[$i] = $i;
	}
	$optionsPhut=array("00" => '00',"01"=> '01',"02"=> '02',"03"=> '03',"04"=> '04',"05"=> '05',"06"=> '06',"07"=> '07',"08"=> '08',"09"=> '09');
	for ($i = 10; $i <= 59; $i++){
		$optionsPhut[$i] = $i;
	}
	$optionsGiay=array("00" => '00',"01"=> '01',"02"=> '02',"03"=> '03',"04"=> '04',"05"=> '05',"06"=> '06',"07"=> '07',"08"=> '08',"09"=> '09');
	for ($i = 10; $i <= 59; $i++){
		$optionsGiay[$i] = $i;
	}
	
	$gio_tu	=  explode(" ",$this->Item['ngaybatdau']);//var_dump($gio_tu);
	$this->Item['ngaybatdau']=$gio_tu[0];
	$gio	=  explode(":",$gio_tu[1]);
	$this->Item['gio_tu']= $gio[0];
	$this->Item['phut_tu']= $gio[1];
	$this->Item['giay_tu']= $gio[2];
	
	$ngaygio 	=substr($this->Item['ngayketthuc'],11,19);
	//echo $ngaygio;die;
	$gio_den	=  explode(" ",$this->Item['ngayketthuc']);//var_dump($gio_den);die;
	$this->Item['ngayketthuc']= $gio_den[0];
	//$gio_d	=  (explode(":", $gio_den[2]));
	$gio_d	=  (explode(":",$ngaygio));
	$this->Item['gio_den']= $gio_d[0];//echo $this->Item['gio_den'];die;
	$this->Item['phut_den']= $gio_d[1];
	$this->Item['giay_den']= $gio_d[2];
	
	$slbGioTu 			= $this->formSelect('gio_tu',$this->Item['gio_tu'],array('style' => 'float: none;'), $optionsGio);
	$slbPhutTu 			= $this->formSelect('phut_tu',$this->Item['phut_tu'],array('style' => 'float: none;'), $optionsPhut);
	$slbGiaytu 			= $this->formSelect('giay_tu',$this->Item['giay_tu'],array('style' => 'float: none;'), $optionsGiay);
	
	$slbGioDen 				= $this->formSelect('gio_den',$this->Item['gio_den'],array('style' => 'float: none;'), $optionsGio);
	$slbPhutDen 			= $this->formSelect('phut_den',$this->Item['phut_den'],array('style' => 'float: none;'), $optionsPhut);
	$slbGiayDen 			= $this->formSelect('giay_den',$this->Item['giay_den'],array('style' => 'float: none;'), $optionsGiay);
	
	//var_dump($gio);die; 
	$ngaybatdau	 			= $this->formText ('ngaybatdau', $this->Item['ngaybatdau'], array ('class' => 'hasDatePicker active','style'=>'min-width:200px;', 'onchange'=>"get_alias()") );
	$ngayketthuc	 		= $this->formText ('ngayketthuc', $this->Item['ngayketthuc'], array ('class' => 'hasDatePicker active','style'=>'min-width:200px;', 'onchange'=>"get_alias()") );
	
	
	$content 		= $this->cmsEditor('content',htmlspecialchars_decode($this->Item['content']),array('toolbar'=>'MyToolbar', 'language'=>'vi'));
	
	
	$arrInput = array(
				//array('label' => 'Chọn ngôn ngữ','input' => $selectLanguages),
				array('label' => 'Tên chương trình khuyến mãi','input' => $name, 'desc' => '<span class="red">*</span>'),
				array('label' => 'KM trực tiếp tính theo (VNĐ)','input' => $giagiam),
				array('label' => 'KM trực tiếp tính theo (%)','input' => $phantram),
				array('label' => 'Ngày bắt đầu','input' => $ngaybatdau . ' - Giờ '.$slbGioTu.' Phút '.$slbPhutTu.' Giây '.$slbGiaytu),
				array('label' => 'Ngày kết thúc','input' => $ngayketthuc.' - Giờ '.$slbGioDen.' Phút '.$slbPhutDen.' Giây '.$slbGiayDen),
				array('label' => 'Mô tả','input' => $content, 'cols' => 2,'style' => 'padding-top:0;'),
			);
	
	
	//--------------------- Blocks ---------------------
	
	if(count($this->messageError)>0){
		$errors = $this->formErrors($this->messageError,array('id'=>'errors'));
	}
?>


<div class="left_content">
	<?php echo $this->render($this->arrParam['controller'] . '/toolbar/left.php');?>
	
</div>


<div class="right_content" style="background: #fff !important;">
	
	<div class="appContent">
	
		<?php echo $this->render('admin-khuyenmai/toolbar/index.php');?>
	 	<div class="clr"></div>
		<?php //echo $this->render('admin-coso/sublink/index.php');?>
		<?php echo $errors;?>
	<form name="appForm" method="post" action="" enctype="multipart/form-data">
	 <div id="tabs">
				<ul>
					<li><a href="#tabs-1">Sửa thông tin khuyến mại</a></li>
				</ul>
	<div id="tabs-1">
	<div class="tblForm">
	
		<!-- BEGIN: CONTENT -->
		<div class="app_content goc10">
			<div class="width-60 fl"> 
					<table class="adminformlist">
						<?php echo $this->partialLoop('row.php', $arrInput);?>
					</table>
				 
			</div>
			
			<div class="clr"></div>
		</div>
		<!-- END: 	CONTENT -->
		</div> </div> </div> 
	</form>
	</div></div>